﻿/*
 * UdpSecureConnection.h
 */
#ifndef __GDK_UDPSECURECONNECTION_H__
#define __GDK_UDPSECURECONNECTION_H__


#include <gdk/net/UdpReliableConnection.h>
#include <gdk/net/SecureSession.h>



namespace gdk
{


////////////////////////////////////////
class GDK_NET_EXPORT UdpSecureConnection : public UdpReliableConnection
{
	DECLARE_CLASS_HANDLE(UdpSecureConnection)
	DECLARE_CLASS_INSTANCE(UdpSecureConnection)

	class SecureLayer
	{
	public:
		UdpSecureConnection  *_conn;

	public:
		__INLINE__ SecureLayer(void)
			: _conn(NULL)
		{}

		ssize_t receive(void *buf, ssize_t size);
		ssize_t send(const void *data, ssize_t size);
		String  getUrl(void) const;
	};

private:
	SecureLayer		_secureLayer;
	SecureSession	_secureSession;

protected:
	UdpSecureConnection(void);
	~UdpSecureConnection(void);

public:
	virtual void onTick(uint32_t timeSinceLastTick);
	virtual ssize_t available(void) const;
	virtual ssize_t receive(void *buf, ssize_t size);
	virtual ssize_t send(const void *data, ssize_t size);
	virtual void close(void);
};




}//namespace gdk


#endif //__GDK_UDPSECURECONNECTION_H__
